(function(window, document) {
    let province = document.querySelector("#province");
    let cityData;
    //获取数据
    function getData(data, type) {
        if (type.innerHTML) {
            type.innerHTML = "<option>请选择</option>";
        }
        data.forEach(function(item) {
            let option = document.createElement("option");
            option.value = item.value
            option.innerHTML = item.text;
            type.appendChild(option)
        })
    }
    getData(cityData3, province)

    //省
    province.onchange = function() {
        let val = this.value;
        cityData3.forEach(function(item) {
            if (item.value == val) {
                cityData = item.children;
                getData(cityData, city)
            }
        })
    }

    //市
    city.onchange = function() {
        let val = this.value;
        cityData.forEach(function(item) {
            if (item.value == val) {
                getData(item.children, area)
            }
        })
    }











})(window, document)